<template>
    <view class="bg-content">
        <u-cell-group v-if="tbStore">
            <myImg :obj="tbStore" :sysFile="{fkId: tbStore.id, typeMark: 'store-brand'}" :key="tbStore.id"
                   :customStyle="'pointer-events: none; height: 250px;  width: 100%; background-size: cover; background-repeat: no-repeat; background-position: center;'"
                   :defaultUrl="'/pages/sub/sub2-store-platform/static/default-image/store-brand.jpg'"
                   v-if="tbStore"
            ></myImg>
            <u-cell-item title="营业状态" :arrow="false" use-label-slot>
                <view slot="label">
                    <div style="color: green;" v-if="tbStore.operatingStatus">
                        正在营业
                    </div>
                    <div class="skin-font" v-if="!tbStore.operatingStatus">
                        已关店
                    </div>
                </view>
            </u-cell-item>
            <u-cell-item title="系统分类" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.storeClassText | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="店铺名称" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.name | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="店铺标题" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.title | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="店铺副标题" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.subTitle | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="店铺编号" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.code | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="店铺简介" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.introduction | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="买家收藏数" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.collectNum | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="工作日" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.businessDays | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="营业时间段" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.businessDays | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="店铺类型" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.storeLabel | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="设施服务" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.featureLabel | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="店铺地址" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.address | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="店铺地址" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.coordinate | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="联系电话" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.phone | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="邮箱" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.email | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="开店时间" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.createTime | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="支付宝账号" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.alipayAccount | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="支付宝真实姓" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.alipayRealName | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="每笔最小订单金额" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.minOrderMoney | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="销售模式" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.saleModeText | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="是否开启线上退款功能" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.isSupportRefund ? '是' : '否'}}
                </view>
            </u-cell-item>
            <u-cell-item title="买家确认收货是否交易完成" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.isConfirmReceiptFinishOrder ? '是' : '否'}}
                </view>
            </u-cell-item>
            <u-cell-item title="订单运费类型" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.freightTypeText | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="订单运费金额" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.freightMoney | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
            <u-cell-item title="订单免邮金额" :arrow="false" use-label-slot>
                <view slot="label">
                    {{tbStore.freeFreightMinOrderMoney | toEmptyStr('未设置')}}
                </view>
            </u-cell-item>
        </u-cell-group>

        <div style="padding-bottom: 60px;"></div>

        <div class="custom-bottom-bar">
            <div style="width: 100%;" @click="updateOperatingStatus(!globalVariable.userInfo.tbStore.operatingStatus)">
                <u-button :type="globalVariable.userInfo.tbStore.operatingStatus ? 'warning' : 'success'" :custom-style="{height: '50px'}"
                          @click="updateOperatingStatus(!globalVariable.userInfo.tbStore.operatingStatus)">
                    {{globalVariable.userInfo.tbStore.operatingStatus ? '关店' : '开店'}}
                </u-button>
            </div>
            <div style="width: 100%;">
                <u-button type="error" :custom-style="{height: '50px'}"
                          @click="navigateTo('/pages/sub/sub2-store-platform/store-platform/store-platform-store-manage/store-platform-store/store-platform-store-edit/index')">
                    编辑店铺信息
                </u-button>
            </div>
        </div>
    </view>
</template>

<script>

    import {TbStoreService} from "@/dev/services/tb-store.service";
    import myImg from '@/components/my-img'
    import {CommonUtil} from "@/dev/core/utils/common.util";

    export default {
        data() {
            return {
                tbStore: null
            }
        },
        components: {
            myImg
        },
        onShow() {
            const _self = this;
            new TbStoreService().findTbStoreByUserId(_self.globalVariable.userInfo.id).then(result => {
                _self.tbStore = result;
                _self.$forceUpdate();
            });
        },
        methods: {
            updateOperatingStatus(operatingStatus) {
                const _self = this;
                CommonUtil.alert({
                    title: '关店后客户将无法购买你的商品！',
                    content: operatingStatus ? '确定开店营业吗？' : '确定关店吗？',
                    showCancel: true, // 是否显示取消按钮
                    success: function (res) {
                        if (res.cancel) { // 点击取消,默认隐藏弹框
                        } else { // 点击确定
                            new TbStoreService().updateTbStore({
                                id: _self.globalVariable.userInfo.tbStore.id,
                                operatingStatus: operatingStatus
                            }).then(result => {
                                _self.tbStore.operatingStatus = operatingStatus;
                                _self.globalVariable.userInfo.tbStore.operatingStatus = operatingStatus;
                                CommonUtil.alert('操作成功');
                            });
                        }
                    }
                });
            }
        }
    }
</script>

<style lang="scss" scoped>
</style>

